$(function () {
    var seleteDoctorValue = $('#doctorValue').val();
    if (seleteDoctorValue != "") {
        $("#doctor option[value='" + seleteDoctorValue + "']").attr("selected", "selected");
        $("#revisit option[value='" + seleteDoctorValue + "']").attr("selected", "selected");
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/getSfList",
        type: "post",
        success: function (data) {
            var li = "";
            for (var i = 0; i < data.length; i++) {
                li += '<li id="' + data[i].id + '" style="position: relative"><a href="javascript:;">' + data[i].title + '</a><span class="glyphicon glyphicon-remove" style="position: absolute;top: 50%;right: 10px;transform: translateY(-50%)"></span></li>'
            }
            $("#dropdownMenu2Ul").html(li)
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/getJgList",
        type: "post",
        success: function (data) {
            var li = "";
            for (var i = 0; i < data.length; i++) {
                li += '<li id="' + data[i].id + '" style="position: relative"><a href="javascript:;">' + data[i].title + '</a><span class="glyphicon glyphicon-remove" style="position: absolute;top: 50%;right: 10px;transform: translateY(-50%)"></span></li>'
            }
            $("#dropdownMenu1Ul").html(li)
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });

    $("#accordion").accordion({
        collapsible: true
    });

    $(".followRightHeader > button").click(function () {
        var index = $(this).index();
        $(this).addClass('Selection').siblings().removeClass('Selection');
        $(".followRightContents > div").eq(index).show().siblings().hide()
    });

    $("#dropdownMenu2Ul").on('click', 'li', function () {
        var value = $(this).attr('id')
        $.ajax({
            url: Feng.ctxPath + "/doctorLooked/getSfById",
            type: "post",
            data: {
                id: value
            },
            success: function (data) {
                $("#remarks2").val(data.remarks)
                $("#remarks").val(data.remarks)
            },
            error: function (data) {
                alert('没有权限，请联系管理员!');
            }
        });
    });

    $("#dropdownMenu1Ul").on('click', 'li', function () {
        var value = $(this).attr('id');
        $.ajax({
            url: Feng.ctxPath + "/doctorLooked/getJgById",
            type: "post",
            data: {
                id: value
            },
            success: function (data) {
                $("#revisitContent").val(data.remarks)
            },
            error: function (data) {
                alert('没有权限，请联系管理员!');
            }
        });
    });

    $("#dropdownMenu2Ul").on('click', '.glyphicon-remove', function (e) {
        e.stopPropagation();
        var value = $(this).parent().attr('id');
        if (confirm("是否删除此模板？")) {
            $.ajax({
                url: Feng.ctxPath + "/doctorLooked/deleteSfById",
                type: "post",
                data: {
                    id: value
                },
                success: function (data) {
                    Feng.success("删除成功!");
                    window.location.reload();
                },
                error: function (data) {
                }
            });
        }
    });

    $("#dropdownMenu1Ul").on('click', '.glyphicon-remove', function (e) {
        e.stopPropagation();
        var value = $(this).parent().attr('id');
        if (confirm("是否删除此模板？")) {
            $.ajax({
                url: Feng.ctxPath + "/doctorLooked/deleteJgById",
                type: "post",
                data: {
                    id: value
                },
                success: function (data) {
                    Feng.success("删除成功!");
                    window.location.reload();
                },
                error: function (data) {
                }
            });
        }
    });
});